home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
051-075
/
scopedisk68
/
c2mod
/
dates.mod
< prev
next >
Wrap
Text File
|
1995-03-19
|
4KB
|
124 lines
IMPLEMENTATION MODULE Dates;
(*
Routines for manipulating Dates.
Revision history:
0.00
Copyright 1987 by:
Dale W. Thompson, 14500 Dallas Pkwy. #2091, Dallas, TX 75240
This module and/or its procedures may be freely used by anyone,
but please acknowledge its use in any copyright notice of a
publicly distributed program. Thank you.
Please forward any comments, problems, or suggestions to me
at the address given, or to my CompuServe ID 75115,734.
*)
FROM DOSLibrary IMPORT DateStampRec;
FROM M2Conversions IMPORT ConvertCardinal;
FROM Strings IMPORT Insert;
(*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*)
PROCEDURE ParseDate( ds : DateStampRec; VAR date: DateString );
VAR
Weekday : ARRAY [0..21] OF CHAR;
Month : ARRAY [0..11], [0..3] OF CHAR;
Days : ARRAY [0..11] OF CARDINAL;
LeapDays : ARRAY [0..11] OF CARDINAL;
year, month, day, weekday, hour, minute, second : CARDINAL;
PROCEDURE Leap( year : CARDINAL ) : BOOLEAN;
BEGIN
RETURN ( ((year-1976) MOD 4) = 0 );
END (* PROCEDURE *) Leap;
(* overlay CARDINAL number into date string *)
PROCEDURE ic( num, pos : CARDINAL );
VAR s : ARRAY [0..2] OF CHAR;
BEGIN
ConvertCardinal( num MOD 100, 2, s );
date[pos+1] := s[1];
IF (num MOD 100) > 9 THEN
date[pos] := s[0];
END;
END (* PROCEDURE *) ic;
BEGIN
Weekday := "SunMonTueWedThuFriSat";
Month[0] := "Jan"; Days[0] := 31; LeapDays[0] := 31;
Month[1] := "Feb"; Days[1] := 28; LeapDays[1] := 29;
Month[2] := "Mar"; Days[2] := 31; LeapDays[2] := 31;
Month[3] := "Apr"; Days[3] := 30; LeapDays[3] := 30;
Month[4] := "May"; Days[4] := 31; LeapDays[4] := 31;
Month[5] := "Jun"; Days[5] := 30; LeapDays[5] := 30;
Month[6] := "Jul"; Days[6] := 31; LeapDays[6] := 31;
Month[7] := "Aug"; Days[7] := 31; LeapDays[7] := 31;
Month[8] := "Sep"; Days[8] := 30; LeapDays[8] := 30;
Month[9] := "Oct"; Days[9] := 31; LeapDays[9] := 31;
Month[10] := "Nov"; Days[10] := 30; LeapDays[10] := 30;
Month[11] := "Dec"; Days[11] := 31; LeapDays[11] := 31;
day := CARDINAL( ds.dsDays );
weekday := day MOD 7;
year := 1978;
LOOP
IF Leap( year ) THEN
IF day < 366 THEN
EXIT;
ELSE
DEC( day,366 );
END;
ELSE
IF day < 365 THEN
EXIT;
ELSE
DEC( day,365 );
END;
END;
INC( year );
END; (* LOOP *)
INC( day );
month := 0;
IF Leap( year ) THEN
WHILE day > LeapDays[month] DO
DEC( day, LeapDays[month] );
INC( month );
END;
ELSE
WHILE day > Days[month] DO
DEC( day, Days[month] );
INC( month );
END;
END;
second := CARDINAL(ds.dsTick DIV 50) MOD 60;
minute := CARDINAL(ds.dsMinute);
hour := minute DIV 60;
minute := minute MOD 60;
date := "dow mmm-0d-yy 0h:0m:0s";
date[0] := Weekday[weekday*3];
date[1] := Weekday[weekday*3+1];
date[2] := Weekday[weekday*3+2];
Insert( Month[month], date, 4 );
ic( day, 8 ); ic( year, 11 );
ic( hour, 14 ); ic( minute, 17 );
ic( second, 20 );
END (* PROCEDURE *) ParseDate;
END (* IMPLEMENTATION MODULE *) Dates.